$(function () {
    layui.use(['table','util'], function(){
        var table = layui.table,util=layui.util;
        table.render({
            elem: '#admin'
            ,url:'../../toilet/getAllToilet',
            method:'POST'
            ,even:true
            ,cols: [[
                {field:'id', title: 'ID',width:80}
                ,{field:'cate_name', title: '分类名称'}
                ,{field:'create_time',title:'创建时间',templet: function(d) {return util.toDateString(d.create_time,"yyyy-MM-dd"); } }
                ,{ toolbar: '#barDemo',title:'操作'}
            ]]
            ,page: false,
        });
        table.on('tool(event)',function (obj) {
            if(obj.event === 'del'){
                layer.confirm('确定删除该游戏分类吗,删除后不可撤回', function(index){
                    var data = obj.data;
                    $.ajax({
                        type: "POST",
                        url: "../../tourist/deleteToilet",
                        data: {
                            "id":data.id
                        },
                        dataType: "json",
                        success: function(data){
                            if(data.code==0){
                                obj.del();
                                layer.close(index);
                            }
                            layer.msg(data.msg);
                        }
                    });
                });
            }else{
                //编辑
            }
        })
    });
})